<?php

use Biz\Constants\Order\OrderConstants;
use Biz\Constants\Site\SiteOrderConstants;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * SiteOrder.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SiteOrder extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('site_order', function (Blueprint $table) {
            $table->bigIncrements('id');//BigID unsigned
            $table->bigInteger('site_id')->unsigned();//站点ID
            $table->bigInteger('user_id')->unsigned();//站点ID
            $table->string('type', 32)->default(SiteOrderConstants::TYPE_STANDARD);// 如注册缴费订单、酒店预定订单
            $table->string('order_no',128);//订单编号,唯一
            $table->string('currency',6)->index();// 货币标识符
            $table->decimal('total_amount',19,4);// 总金额
            $table->string('status', 32)->default(OrderConstants::STATUS_ORDER_CREATE);//状态

            // 注意时间戳位数
            $table->timestamps();
            $table->softDeletes();

            // index
            $table->index('site_id');
            $table->index('user_id');
            $table->unique('order_no');
            $table->index(['site_id', 'type']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('site_order');
    }
}